package com.zhongjinkang.rhythm.AppView.Dialog

import android.os.Bundle
import android.os.Handler
import android.os.Message
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup

import com.zhongjinkang.rhythm.databinding.DialogLoadingIosBinding


class LoadingDialog : BaseDialog() {
    private lateinit var binding: DialogLoadingIosBinding;
    private val TIME_OUT=1;
    private val timeout:Int=30*1000
    private val handler:MHandler=MHandler()


    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = DialogLoadingIosBinding.inflate(inflater, container, false)
        return binding.root
    }






    override fun showDialog() {
     handler.sendEmptyMessageDelayed(TIME_OUT,timeout.toLong());
    }

    override fun hideDialog() {
        handler.removeCallbacksAndMessages(null)
        binding.progressBar1.clearAnimation()
    }
    inner class  MHandler : Handler() {
        override fun handleMessage(msg: Message) {
            super.handleMessage(msg)
            if (msg.what==TIME_OUT){
                dismissAllowingStateLoss()

            }
        }
    }

}